<!DOCTYPE HTML>
<html lang="zh-cn">
  <head>
    <meta charset="UTF-8">
    <title>Powerful JQuery Plugins</title>
    <link href="/js/jQueryUI/jquery-ui.css" type="text/css" rel="stylesheet"></link>
    <link href="/js/jQueryScrollbar/perfect-scrollbar.css" type="text/css" rel="stylesheet"></link>
  </head>
  
  <body>
    <a href="#"></a>
    <a href="#"></a>
    <a href="#"></a>
    <a href="#"></a>
    <a href="#"></a>
    <script src="/js/jQuery/jquery-1.11.3.js" type="text/javascript"></script>
    <script src="/js/jQueryUI/jquery-ui.js" type="text/javascript"></script>
    <script src="/js/jQueryValidation/jquery.validate.js" type="text/javascript"></script>
    <script src="/js/jQueryValidation/messages_zh.js" type="text/javascript"></script>
    <script src="/js/jQueryValidation/additional-methods.js" type="text/javascript"></script>
    <script src="/js/jQueryValidation/additional-methods.js" type="text/javascript"></script>
    <script src="/js/jQueryScrollbar/perfect-scrollbar.jquery.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(function() {
            console.info("Dom元素加载完毕！");
            console.info($("a").length);
            console.info(typeof $("a"));
            $("a").each(function(index) {
                $(this).attr({
                    rel: "rel" + index,
                    href: function(idx, href) {
                        return idx + "/new" + href;
                    }
                }).text(index);                 
            });
            //如果选择器一次取得多个元素，直接使用索引取得的是原生对象，需要是使用$重新封装才行
            $($("a")[0]).text("修改");
            $("a").eq(2).text("修改");
            $("a:last").text("修改");
            $("a:odd").text("奇数");
            $("a").each(function(index) {
                //idx一直为0，作用不确定
                $(this).attr("href", function(idx, href) {
                    console.log(idx + href);
                });                 
            });
        });
    </script>
  </body>
</html>
